<template>
	<view class="index-list animated fadeInLeft fast">
		<view class="index-list1 u-f-ac u-f-jsb">			
			<view class="u-f-ac">
				<image :src="item.userpic" mode="widthFix" lazy-load></image>
				{{item.username}}
			</view>
			<view class="u-f-ac" v-show="!isguanzhu" @tap="handleFocusClick(item)">	
				<view class="icon iconfont icon-zengjia"></view>
				关注
			</view>
		</view>
		<view class="index-list2" @tap="handleNavgateToDetail(item)">
			{{item.title}}
		</view>
		<view class="index-list3 u-f-ajc">
			<!-- 图片 -->
			<image :src="item.titlepic" mode="widthFix" lazy-load @tap="handleNavgateToDetail(item)"></image>
			<template v-if="item.type == 'video'">
				<!-- 视频 -->
				<view class="index-list-play icon iconfont icon-bofang"></view>
				<!-- 播放次数 -->
				<view class="index-list-playinfo">
					{{item.playnum}}次播放 {{item.long}}
				</view>
			</template>
		</view>
		<view class="index-list4 u-f-ac u-f-jsb">
			<view class="u-f-ac">
				<view class="u-f-ac" :class="{'active': infonum.index == 1}">
					<view class="icon iconfont icon-icon_xiaolian-mian" @tap="handleDingClick('ding')"></view>{{ infonum.dingnum }}
				</view>
				<view class="u-f-ac" :class="{'active': infonum.index == 2}">
					<view class="icon iconfont icon-kulian" @tap="handleDingClick('cai')"></view>{{ infonum.cainum }}
				</view>
			</view>
			<view class="u-f-ac">
				<view class="u-f-ac">
					<view class="icon iconfont icon-pinglun1"></view>{{ item.commentnum }}
				</view>
				<view class="u-f-ac">
					<view class="icon iconfont icon-zhuanfa"></view>{{ item.sharenum }}
				</view>
			</view>
		</view>		
	</view>
</template>

<script>
	export default {
		name:"index-list",
		props:{
			item: Object,
			index: Number
		},
		data() {
			return {
				isguanzhu: this.item.isguanzhu,
				infonum: this.item.infonum
			}
		},
		methods: {
			// 点击关注
			handleFocusClick() {
				this.isguanzhu = true
				uni.showToast({
					title:"关注成功"
				})
			},
			
			// 顶踩
			handleDingClick(type) {
				console.log(type, 1232)
				// infonum: {
					// index: 0, 未操作, 1顶, 2踩
					// 
				// }
				switch(type) {
					case 'ding':
						if(this.infonum.index == 1) return
						if(this.infonum.index == 2) {this.infonum.cainum-- }
						this.infonum.dingnum++
						this.infonum.index = 1
					break;
					case 'cai':
						if(this.infonum.index == 2) return
						if(this.infonum.index == 1) {this.infonum.dingnum-- }
						this.infonum.cainum++
						this.infonum.index = 2
					break;
				}
			},
			// 点击跳转详情
			handleNavgateToDetail(row){}
		}
	}
</script>

<style scoped>
	.index-list{
		padding: 20upx;
		border-bottom: 1upx solid #eee;
	}

	.index-list1 > view:first-child {
		color: #999;
	}
	
	
	
	.index-list1 > view:first-child image{
		width: 90upx;
		height: 90upx;
		border-radius: 50%;
		margin-right: 10upx;
	}
	
	.index-list1 > view:last-child {
		
		background-color: #f4f4f4;
		border-radius: 5rpx;
		padding: 0 10upx;
	}
	
	
	.index-list2{
		padding-top: 15upx;
		font-size: 32upx;
	}
	.index-list3{
		padding-top: 15upx;
		position: relative;
	}
	.index-list3>image{
		width: 100%;
		border-radius: 20upx;
	}
	.index-list4{
		padding: 15upx 0;
	}
	
	.index-list4 view {
		color: #999;
	}
	
	
	.index-list4 > view > view:first-child,
	.index-list4 > view > view>view{
		margin-right: 10upx;
	}
	
	.index-list4 .active, .index-list4 .active> view {
		color: #C5F61C;
	}
	
	.index-list-play {
		position: absolute;
		font-size: 120upx;
		color: #FFFFFF;
	}
	
	.index-list-playinfo {
		position: absolute;
		background-color: rgba(51, 51, 51, 0.72);
		color: #FFFFFF;
		bottom: 8upx;
		right: 8upx;
		border-radius: 40upx;
		font-size: 22upx;
		padding: 0 12upx;
	}
</style>
